import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/components/views/layout/Index.vue'
import Login from '@/components/views/login/Index.vue'
import Home from '@/components/views/home/Home.vue'


// 懒加载
const Product = ()=>import('@/components/views/product/Index.vue')
const List = ()=>import('@/components/views/product/list/Index.vue')
const Category= ()=>import('@/components/views/product/category/Index.vue')

const Order = ()=>import('@/components/views/order/Index.vue')
const OrderList= ()=>import('@/components/views/order/list/Index.vue')
const Collect= ()=>import('@/components/views/order/collect/Index.vue')

const Advert = ()=>import('@/components/views/advert/Index.vue')
const AdvertList = ()=>import('@/components/views/advert/list/Index.vue')

Vue.use(VueRouter)

const routes = [
    {
        path:'/',
        component:Layout,
        children:[{
            path:'/',
            name:'home',
            component:Home,
        },
    {
        path:'/product',//产品
        name:'prodcut',
        component:Product,
        children:[{
            path:'list',//默认路径:/prodeuct 我们只需list 即等于/product/list  
            name:'list',
            component:List,
        },
        {
            path:'category',  
            name:'category',
            component:Category,
        },
        ],
    },
    {
        path:'/order',//订单
        name:'order',
        component:Order,
        children:[{
            path:'order-list',
            name:'order-list',
            component:OrderList,
        },
        {
            path:'collect',  
            name:'collect',
            component:Collect,
        },
        ],
    },
    {
        path:'/advert',//广告
        name:'advert',
        component:Advert,
        children:[{
            path:'advert-list', 
            name:'advert-list',
            component:AdvertList,
        },
        ],
    },
],
    },
    {
        path:'/login',
        name:'login',
        component:Login
    }
    // {
    //     path: '*', // Catch-all route for 404 Not Found
    //     name: 'not-found',
    //     component: NotFound,
    // }
];

const router = new VueRouter({
    mode: 'history',//历史路由
    base: process.env.BASE_URL,
    routes
});


export default router;